package com.wise.file.server.service.impl;

import com.wise.file.server.domain.ImageFile;
import com.wise.file.server.repository.ImageFileRepository;
import com.wise.file.server.service.ImageFileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class ImageFileServiceImpl implements ImageFileService {

    @Autowired
    private ImageFileRepository repository;

    @Override
    public void remove(String id) {
        repository.deleteById(id);
    }

    @Override
    public ImageFile saveImageFile(ImageFile file) {
        return repository.save(file);
    }

    @Override
    public ImageFile findFileById(String id) {
        return repository.findById(id).get();
    }

    @Override
    public List<ImageFile> listFiles() {
        return repository.findAll();
    }
}
